package com.analyze.datasource.po;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.ForeignKey;

@Entity(name="datasource")
public class DataSource implements Serializable{
	private Long id;
	private String name;
	private String host;
	private String port;
	private String dbName;
	private DatabaseDriver driver;
	private String userName;
	private String password;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id", unique = true, nullable = false, insertable = true, updatable = true)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "name", unique = false, nullable = true, insertable = true, updatable = true)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "host", unique = false, nullable = true, insertable = true, updatable = true)
	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}

	@Column(name = "port", unique = false, nullable = true, insertable = true, updatable = true)
	public String getPort() {
		return port;
	}

	public void setPort(String port) {
		this.port = port;
	}

	@Column(name = "db_name", unique = false, nullable = true, insertable = true, updatable = true)
	public String getDbName() {
		return dbName;
	}

	public void setDbName(String dbName) {
		this.dbName = dbName;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.EAGER)
	@ForeignKey(name="FK_database_drive_id")
	@JoinColumn(name = "data_driver_id", nullable = true, insertable = true, updatable = true)
	public DatabaseDriver getDriver() {
		return driver;
	}

	public void setDriver(DatabaseDriver driver) {
		this.driver = driver;
	}

	@Column(name = "user_name", unique = false, nullable = true, insertable = true, updatable = true)
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	@Column(name = "user_password", unique = false, nullable = true, insertable = true, updatable = true)
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
}
